package com.wgh.api.client.fallback;

import com.wgh.api.client.order.OrderClient;
import com.wgh.order.dto.OrderDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 订单服务客户端熔断降级实现
 */
@Component
@Slf4j
public class OrderClientFallback implements OrderClient {

    @Override
    public OrderDTO createOrder(Map<String, Object> orderParams) {
        log.error("订单服务调用失败，降级处理：createOrder(orderParams={})", orderParams);
        return null;
    }

    @Override
    public OrderDTO findById(Long id) {
        log.error("订单服务调用失败，降级处理：findById(id={})", id);
        return null;
    }

    @Override
    public List<OrderDTO> findListByUserId(Long userId, Integer page, Integer size) {
        log.error("订单服务调用失败，降级处理：findListByUserId(userId={}, page={}, size={})", userId, page, size);
        return new ArrayList<>();
    }

    @Override
    public Boolean updateOrderStatus(Long orderId, Integer status) {
        log.error("订单服务调用失败，降级处理：updateOrderStatus(orderId={}, status={})", orderId, status);
        return false;
    }

    @Override
    public Boolean cancelOrder(Long orderId) {
        log.error("订单服务调用失败，降级处理：cancelOrder(orderId={})", orderId);
        return false;
    }
}